//
//  VBSorcerer.m
//  VicBattle
//
//  Created by Nguyen Nguyen on 5/6/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "VBSorcerer.h"
#import "VBBattleLayer.h"

@implementation VBSorcerer

-(id) initWithWorld:(VBBattleLayer *) world
{
    if((self=[super init]))
    {
        battle = world;
        
        body = [CCSprite spriteWithSpriteFrameName:@"sorcerer_idle_01.png"];
        
        id anime = [[CCAnimationCache sharedAnimationCache] animationByName:@"sorcererSouthIdle"];
        id act = [CCAnimate actionWithDuration:0.7f animation:anime restoreOriginalFrame:NO];
        [body runAction:[CCRepeatForever actionWithAction:act]];
        
        [battle addChild:body];
        
        life = 100;
        if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        {
            hpBar = [CCProgressTimer progressWithFile:@"hpBar-hd.png"];
            [hpBar setPosition : ccp(65, body.contentSize.height - 30)];
        }
        else
        {
            hpBar = [CCProgressTimer progressWithFile:@"hpBarIphone.png"];
            [hpBar setPosition : ccp(45, body.contentSize.height - 20)];
        }
        
        hpBar.type = kCCProgressTimerTypeHorizontalBarLR;
        hpBar.percentage = life;
        
        [body addChild: hpBar];
    }
    return self;
}

@end
